<?php

namespace app\api\validate;

use think\Validate;

class HelpValidate extends Validate
{
    /**
     * 验证规则
     */
    protected $rule = [
        'id' => 'require|integer|>:0',
        'page' => 'require|integer|>:0',
        'limit' => 'require|integer|>:0',
        'keyword' => 'max:50',
    ];

    /**
     * 提示消息
     */
    protected $message = [
        'id.require' => 'id不能为空',
        'id.integer' => 'id必须为整数',
        'id.>0' => 'id必须大于0',
        'page.require' => 'page不能为空',
        'page.integer' => 'page必须为整数',
        'page.>0' => 'page必须大于0',
        'limit.require' => 'limit不能为空',
        'limit.integer' => 'limit必须为整数',
        'limit.>0' => 'limit必须大于0',
        'keyword.max' => '关键词最多不能超过100个字符',
    ];

    /**
     * 字段描述
     */
    protected $field = [
    ];

    /**
     * 验证场景
     */
    protected $scene = [
        // 列表
        'list'  => [
            'page' => ['require', 'integer', '>:0'],
            'limit' => ['require', 'integer', '>:0'],
            'level' => ['in:1,2,3'],
            'keyword' => ['max:100'],
        ],
        // 详情
        'detail' => [
            'id' => ['require', 'integer', '>:0'],
        ]
    ];

}